package cn.smile.controller.msg;

import cn.smile.bean.form.msg.mail.SendEmailForm;
import cn.smile.business.msg.IEmailInfoService;
import cn.smile.commons.enums.msg.MailCodeEnum;
import cn.smile.commons.response.MyResult;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import jakarta.annotation.Resource;

/**
 * @author smile-jt
 */
@RestController
@RequestMapping("api/email")
public class EmailController {

    @Resource
    private IEmailInfoService service;

    @PostMapping(value = "sendEmail")
    public MyResult<Boolean> sendEmail(@Valid @RequestBody SendEmailForm form) {
        return MyResult.OK(service.sendMail(MailCodeEnum.get(form.getMailCode()), form.getEntity(), form.getReceiveAdd()));
    }
}
